package com.lijiajian.controller;

import com.lijiajian.Service.CustomerService;
import com.lijiajian.base.BaseController;
import com.lijiajian.query.CustomerQuery;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("customerReport")
public class CustomerReportController extends BaseController {
    @Resource
    private CustomerService customerService;
    @GetMapping("contribution")
    @ResponseBody
    public Map<String,Object> queryContribution(CustomerQuery customerQuery){
        return customerService.queryCustomerContribution(customerQuery);
    }

    @GetMapping("report/{type}")
    public String index(@PathVariable("type") Integer type){
        if(type!=null){
            if(type==0){
                //客户贡献分析
                return "customerCount/customerCount";

            }else if(type==1){
                //客户构成分析
                return "customerCount/countCustomerMake";
            }
            else if(type==3){
                //客户流失分析
                return "customerCount/customerCountLoss";

            }
        }
        return "";
    }

    @GetMapping("countCustomerMake")
    @ResponseBody
    public Map<String,Object> countCustomerMake(){
        return customerService.countCustomerMake();
    }

    /**
     * 饼图
     * @return
     */
    @GetMapping("countCustomerMake02")
    @ResponseBody
    public List<Map<String,Object>> countCustomerMake02(){
        return customerService.countCustomerMake02();
    }


}
